from mask_rcnn import MASK_RCNN
from PIL import Image
from utils import gol


mask_rcnn = MASK_RCNN()

while True:
    img = input('Input image filename:')
    try:
        image = Image.open(img)
    except:
        print('Open Error! Try again!')
        continue
    else:
        image = mask_rcnn.detect_image(image)
        # mask1, y = mask_rcnn.mask_image(image)

        # mask1.save('mask1.png', "PNG")
        # size = mask1.shape()
        # print(mask1)

        image.show()
        # mask1.show()

        # 初始化gol模块，只需要在主程序模块初始一次
        # gol._init()
        # 获得某个跨文件全局变量的值： gol.get_value(变量名)
        # num = gol.get_value('num')
        j = 100
        for i in range(j):
            mask2, x = mask_rcnn.mask_every_image(image)
            j = x
            mask2.show()
mask_rcnn.close_session()
    